home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2005 March / Macworld CD March 2005 - Marathon Trilogy.iso / Shareware World / Text Processing / HexEdit Release.sit / HexEdit Release / Project / Source / EditWindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-30  |  5.1 KB  |  154 lines  |  [TEXT/CWIE]

  1. /*
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is Copyright 1993 Jim Bumgardner.
  13.  * 
  14.  * The Initial Developer of the Original Code is Jim Bumgardner
  15.  * Portions created by Lane Roathe (LR) are
  16.  * Copyright (C) Copyright © 1996-2002.
  17.  * All Rights Reserved.
  18.  *
  19.  * Modified: $Date: 2002/08/21 06:41:43 $
  20.  * Revision: $Id: EditWindow.h,v 1.12 2002/08/21 06:41:43 raving Exp $
  21.  *
  22.  * Contributor(s):
  23.  *        Lane Roathe
  24.  *        Nick Shanks (NS)
  25.  *        Scott E. Lasley (SEL) 
  26.  */
  27.  
  28. #include "ObjectWindow.h"
  29.  
  30. #ifndef _HexEdit_EditWindow_
  31. #define _HexEdit_EditWindow_
  32.  
  33. /*** Window Types ***/
  34. typedef enum
  35. {
  36.     kWindowNormal = 0,
  37.  
  38.     kWindowCompareTop = 1,
  39.     kWindowCompareBtm = 2,
  40.  
  41.     kWindowTypeCount
  42.  
  43. }tWindowType;
  44.  
  45. /*** EDIT CHUNK ***/
  46. typedef struct EditChunk
  47. {
  48.     struct EditChunk    **prev,**next;
  49.     Boolean                loaded;            // Flag if chunk is currently loaded
  50.     short                type;            // 0=Orig File, 1=Work File, 2=Unwritten
  51.     Handle                data;            // Handle to Chunk Data
  52.     long                size;            // Size of Chunk
  53.     long                allocSize;        // Size of allocated Pointer
  54.     long                addr;            // Start Addr in updated File
  55.     long                filePos;        // Start Addr in actual File
  56.     long                lastCtr;        // Use Counter
  57. }    EditChunk;
  58.  
  59. /*** EDIT WINDOW ***/
  60. typedef struct
  61. {
  62.     ObjectWindowRecord    oWin;            // Window Record
  63.     ControlHandle        vScrollBar;        // Vertical Scroll Bar
  64.  
  65.     EditChunk            **firstChunk;    // File's First Chunk
  66.     EditChunk            **curChunk;        // File's Current Chunk
  67.     long                useCtr;            // Chunk access Counter
  68.                                         // Chunks are unloaded from memory based on usage
  69.     long                totLoaded;        // Amount of bytes in Memory
  70.  
  71.     FSSpec                fsSpec,workSpec;// File Specs for Original, Work File
  72.     FSSpec                destSpec;        // File Spec for Save, Save As
  73.  
  74.     /* very latest type of info */
  75. #if !defined(__MC68K__) && !defined(__SC__)
  76.     FSCatalogInfo         catinfo;        // File permissions (including unix bytes, etc.)
  77.     long                OKToSetCatInfo;    // true if no error getting permissions
  78. #endif
  79.  
  80.     /* old type of info */
  81.     long                fileSize;        // Total File Size
  82.     long                fileType;        // File Type
  83.     long                creator;        // File Creator
  84.     unsigned long        creationDate;    // Creation Date
  85.  
  86.     short                refNum;            // File's Reference Number
  87.     short                workRefNum;        // Work File's Reference Number
  88.  
  89.     long                editOffset;        // Display Offset
  90.     long                startSel;        // First Character of Selection
  91.     long                endSel;            // First Character AFTER Selection
  92.     long                lastTypePos;    // Last Typing Insertion Point
  93.     long                workBytesWritten;    // Size of Work File
  94.     long                linesPerPage;    // Lines that fit in the theWin
  95.  
  96.     EditMode            editMode;        // defines whether we are in the hex or ascii portion
  97.     short                fork;            // 0=data 1=resource
  98.     short                lastNybble;        // Last Hex Edit Nibble
  99.  
  100.     Boolean                loByteFlag;        // Editing Low Byte for Hex Editor
  101.     Boolean                dirtyFlag;        // File has been modified
  102.     Boolean                readOnlyFlag;    // File is read-only!
  103.  
  104. //LR 180    GWorldPtr            offscreen;
  105.  
  106.     short                csResID;        // LR: color table res ID for drawing theWin
  107.     short                csMenuID;        //LR 181 -- menu ID of window's color (for nice window updates)
  108.  
  109. }    EditWindowRecord, *EditWindowPtr;
  110.  
  111. void InitializeEditor( void );
  112. void CleanupEditor( void );
  113. GWorldPtr NewCOffScreen( short width, short height );
  114. void NewEditWindow( void );
  115. OSStatus OpenEditWindow( FSSpec *fsSpec, tWindowType type, Boolean showerr );
  116. void DisposeEditWindow( WindowRef theWin );
  117. Boolean    CloseEditWindow( WindowRef theWin );
  118. Boolean CloseAllEditWindows( void );
  119. void SizeEditWindow( WindowRef theWin, tWindowType type );
  120. EditWindowPtr LocateEditWindow( FSSpec *fs, short fork );
  121. EditWindowPtr FindFirstEditWindow( void );
  122. EditWindowPtr FindNextEditWindow( EditWindowPtr curr );
  123. void MyDraw( WindowRef theWin );
  124. void UpdateOnscreen( WindowRef theWin );
  125. void MyIdle( WindowRef theWin, EventRecord *er );
  126. void MyHandleClick( WindowRef theWin, Point where, EventRecord *er );
  127. void PrintWindow( EditWindowPtr dWin );
  128. void MyProcessKey( WindowRef theWin, EventRecord *er );
  129. void CursorOff( WindowRef theWin );
  130. void CursorOn( WindowRef theWin );
  131. void SaveContents( WindowRef theWin );
  132. void SaveAsContents( WindowRef theWin );
  133. void RevertContents( WindowRef theWin );
  134. void MyActivate( WindowRef theWin, Boolean active );
  135. void UpdateEditWindows( void );
  136.  
  137. // In order to support Nav and SF we have to go through some pain
  138.  
  139. short AskEditWindowNav( tWindowType type );
  140. #if !TARGET_API_MAC_CARBON
  141. short AskEditWindowSF( tWindowType type );
  142. #endif
  143.  
  144. // BB: now a wrapper for Nav or SF based functions
  145. #if __MWERKS__ && !__POWERPC__        //LR 1.73 -- not available for 68K (won't even link!)
  146.     #define AskEditWindow AskEditWindowSF
  147. #elif !TARGET_API_MAC_CARBON
  148. inline short AskEditWindow( tWindowType type )
  149. {if (g.useNavServices) {return AskEditWindowNav( type );} else {return AskEditWindowSF( type );}}
  150. #else
  151.     #define AskEditWindow AskEditWindowNav
  152. #endif
  153.  
  154. #endif